<?php

// 测试方法  http://localhost/phplearn/redis/Scan.php


// Connecting to Redis server on localhost
$redis = new Redis ();
$redis->connect ( '127.0.0.1', 6379 );
 // check whether server is running or not
 //echo "SCAN:[".__FILE__."] line:[".__LINE__."]     result：". '12' . "<br/>\r\n";

echo "Server is running: ".$redis->ping (). "<br/>\r\n";;

$redis->setOption(Redis::OPT_SCAN, Redis::SCAN_RETRY);   //有啥用？

//方法一  设置count 
$match = '*queue';
$count = 10000;
// while ($keys = $redis->scan($it, $match, $count)) {
// 	 var_dump($keys);
//    $redis->del($keys);  //数组内的数据都被删除
// }
 

// 方法二  $interator
$ii = 0;
$iterator=null;
do  {
	echo   $count;
 	//$keys = $redis->scan($iterator, $match );
	$keys = $redis->scan($iterator, $match , $count);
	var_dump($keys);
	var_dump($iterator);
	$ii ++;
	
 	foreach ($keys as $i => $value) {
		//unset($array[$i] ); 
	}

} while($iterator !==0 || $count== 1 );

 






